//
//  LoginStatuesModel.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/10/13.
//  Copyright © 2017年 bob. All rights reserved.
//用户信息管理类。

#import "LoginStatuesModel.h"

@implementation LoginStatuesModel

//保存登陆数据
+(void)SaveUserInforWithModel:(LoginStatuesModel*)model
{
    
    [USER_DEFAULT setObject:model.mj_keyValues forKey:@"TBUserInfor"];
    
}

+(NSDictionary*)GetCach
{
    NSDictionary*dict=  [USER_DEFAULT objectForKey:@"TBUserInfor"]!=nil?[USER_DEFAULT objectForKey:@"TBUserInfor"]:@{};
    
    if ([dict allKeys].count!=0) {
        
        return dict[@"data"];
    }
    
    return @{};
}

//获取useid
+(NSString*)getUserToken
{
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"token"]) {
        
        return [dict objectForKey:@"token"];
        
    }
    
    return @"";
    
}
//获取用户名
+(NSString*)getLoginName
{
    
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"loginName"]) {
        
        return [dict objectForKey:@"loginName"];
        
    }
    
    return @"";
    
}

//获取用户昵称
+(NSString*)getStaffName
{
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"staffName"]) {
        
        return [dict objectForKey:@"staffName"];
        
    }
    return @"";
}

//获取头像
+(NSString*)getuserPhoto
{
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"staffPhoto"]) {
        
        return [dict objectForKey:@"staffPhoto"];
        
    }
    return @"";
    
}

//获取用户类型
+(NSInteger)getUserType
{
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"loginType"]) {
        
        return [[dict objectForKey:@"loginType"]integerValue];
        
    }
    return 1;
    
}

//用户ID
+(NSInteger)getStaffId
{
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"staffId"]) {
        
        return [[dict objectForKey:@"staffId"]integerValue];
        
    }
    return 0;

}

//获取商户审核状态
+(NSInteger)shopStatus
{
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"shopStatus"]) {
        
        return [[dict objectForKey:@"shopStatus"]integerValue];
        
    }
    return 0;
}
//获取商户shopid
+(NSInteger)shopId
{
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"shopId"]) {
        
        return [[dict objectForKey:@"shopId"]integerValue];
        
    }
    return 0;

}


//获取商户名字
+(NSString*)shopName
{
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"shopName"]) {
        
        return [dict objectForKey:@"shopName"];
        
    }
    return @"";

}

//获取商户类型
+(NSInteger)shoptype
{
    
    NSDictionary *dict=[self GetCach];
    
    if ([[dict allKeys]containsObject:@"type"]) {
        
        return [[dict objectForKey:@"type"]integerValue];
        
    }
    return 0;
    
}

//清除登陆数据
+(void)CleanUserInfor
{
      SetLoadIP(@"");
    [USER_DEFAULT setObject:nil forKey:@"TBUserInfor"];
    
}

@end

@implementation LoginData

+ (NSDictionary *)objectClassInArray{
    return @{@"menus" : [LoginMenus class]};
}

@end


@implementation LoginMenus

+(NSDictionary*)mj_replacedKeyFromPropertyName
{
    
    return @{@"ID":@"id"};
    
}

@end



